package base.support;

import java.io.IOException;

import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class IsNewTag extends SimpleTagSupport
{
	private long value = 0;
	private int day = 7;

	public void setValue(long value)
	{
		this.value = value;
	}

	public void setDay(int day)
	{
		this.day = day;
	}

	public void doTag() throws JspException, IOException
	{
		JspContext ctx = getJspContext();
		JspWriter out = ctx.getOut();

		long time = System.currentTimeMillis() - value;

		if (time < day * 86400 * 1000)
		{
			out.print("<img src='images/new.gif' />");
		}
	}
}
